<?php
require_once MODULE_PATH .'/cms/link.php';

class C_News extends C_Abstract
{   
    public function indexAction()
    {
        $id = getGet('id', 0, 'int');
        if ($id) {
            $data = \Modules\Cms\Link::fetchOne($id);
            $near = \Modules\Cms\Link::fetchNear($data['idx'], $data['sort']);
            $this->smt->assign('data', $data);
            $this->smt->assign('near', $near);
            $this->smt->display('news_detail.html');
        } else {
            $num = 2;
            $list = \Modules\Cms\Link::fetch('news', $this->_idx, $num, $this->_page);
            $this->smt->assign('list', $list);
            $this->smt->assignByRef('pages', \Modules\Cms\Link::getPages($this->_page, $num, 'data'));
            $this->smt->assign('page_url', '\?c=news&');
            $this->smt->display('news.html');
        }
    }
}